<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>

<div class="p10t">
  <div class="tt3">
    <p class="text_tt1">Registere</p>
  </div>
  <div class="box_pro p10t">
    <?php
		if(JRequest::getVar('success','0','get' )=='1'){
	?>
    Success
    <?php
		}
	?>
    <form action="<?php echo JRoute::_('index.php'); ?>" class="form-validate" method="post" name="registerForm" id="registerForm">
      <div class="p27l p15b p30t box_mail">
        <h5 class="p10b">Velkommen til <span class="style2">XEscort.dk</span></h5>
        <p class="p26r"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris nec mauris at diam placerat tempus vel quis sapien. Maecenas mattis leo non ante posuere at egestas massa pretium. Etiam ac tortor arcu. Fusce ac tincidunt quam. Curabitur gravida sollicitudin metus, eget auctor lorem euismod at.</p>
        <br>
        <label>Din profils navn:</label>
        <input type="text" name="name" id="name" class="txt_mail w322" onchange="checkusername();">
		<input type="hidden" name="username" id="username" value="" class="txt_mail w322"/>
        <br class="cb">
        <label>Køn:</label>
        <select name="gender" id="gender" class="txt_list w84 float_left">
          <option value="">Vælg</option>
          <option value="0">Mandlige</option>
          <option value="1">Kvindelige</option>
        </select>
        <span class="float_left p10l p12r p5t">Område:</span>
        <select name="location" id="location" class="txt_list w176 float_left">
          <option value="">Vælg</option>
          <option value="Denmark">Denmark</option>
		  <option value="VietNam">VietNam</option>
        </select>
        <br class="cb">
        <label>Vælg et kodeord:</label>
        <input type="password" name="password" id="password" class="txt_mail w322">
        <input type="hidden" name="password2" id="password2" class="txt_mail w322">
        <br class="cb">
        <label>Telefonnr:</label>
        <input type="text" name="telephone" id="telephone" class="txt_mail w322">
        <br class="cb">
        <label>Hjemmeside:</label>
        <input type="text" name="hometown" id="hometown" class="txt_mail w322">
        <br class="cb">
        <label>E-mail adresse:</label>
        <input type="text" name="email" id="email" class="txt_mail w322" onchange="checkemail();">
        <br class="cb">
        <label>Kort annoncetekst:</label>
        <textarea rows="" cols="" name="shorttext" id="shorttext" class=" w322"></textarea>
        <br class="cb">
        <label>&nbsp;</label>
        <a href="javascript:void(0);" onclick="click_send();"><img src="templates/xescort/images/bt_send.png" /></a> <a href="javascript:void(0);" onclick="reset_form();"><img src="templates/xescort/images/bt_nulstil.png" /></a> </div>
      <div class="box_pro p15b p15t">
        <table cellspacing="0" cellpadding="0" border="0" width="100%">
          <tbody>
            <tr>
              <td width="6%">&nbsp;</td>
              <td width="13%"><img src="template/xescort/images/icon_info.png"></td>
              <td width="81%">Hvis du ønsker at kunne modtage e-mails fra dine besøgende, skal du sætte kryds i feltet nedenfor. Afsenderen kan ikke se din e-mail adresse, så din e-mail adresse er beskyttet.
                <p class="p10t">
                  <input type="checkbox" value="1" name="receivedmail" id="receivedmail">
                  Ja tak, jeg vil gerne kunne modtage e-mail framine besøgende.</p></td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="box_pro p15b p10t">
        <table cellspacing="0" cellpadding="0" border="0" width="100%">
          <tbody>
            <tr>
              <td width="6%">&nbsp;</td>
              <td width="13%">&nbsp;</td>
              <td width="81%"><a href="javascript:void(0);" onclick="click_send();"><img src="templates/xescort/images/bt_opretdinprofilnu.png" /></a> <a href="javascript:void(0);" onclick="reset_form();"> </td>
            </tr>
          </tbody>
        </table>
      </div>
      <input type="submit" name="send" id="send" value="Send" style="display: none;" />
      <input type="hidden" name="task" value="register_save" />
      <input type="hidden" name="id" value="0" />
      <input type="hidden" name="gid" value="0" />
      
      <!--
	  <input type="hidden" name="description" id="description" value="" />
	  <input type="hidden" name="age" id="age" value="" />
	  <input type="hidden" name="height" id="height" value="" />
	  <input type="hidden" name="weight" id="weight" value="" />
	  <input type="hidden" name="weight" id="weight" value="" />
	  <input type="hidden" name="eyecolor" id="eyecolor" value="" />
	  <input type="hidden" name="haircolor" id="haircolor" value="" />
	  <input type="hidden" name="bodyform" id="bodyform" value="" />
	  <input type="hidden" name="website" id="website" value="" />
	  <input type="hidden" name="shorttext" id="shorttext" value="" />
	  <input type="hidden" name="online" id="online" value="0" />
	  <input type="hidden" name="hometown" id="hometown" value="" />	  
	  -->
      <?php echo JHTML::_( 'form.token' ); ?>
    </form>
  </div>
  {module Ads} </div>
<div class="center_bt"></div>
<script language="javascript">
jQuery(document).ready(function($) {	
	
	jQuery("#registerForm").validate({
		errorPlacement: function(error, element) {			
		},
		invalidHandler: function(form, validator) {
		  var errors = validator.numberOfInvalids();
		  if (errors) {
			jQuery('#alert').html(validator['errorList'][0]['message']);
			jQuery('#backoverlay').show();
			jQuery('#show_popup').show();
			jQuery('#f_focus').html(validator['errorList'][0]['element'].name);
			validator['errorList'][0]['element'].focus();
		  } else {
		  }
		},
		rules: {
			name : "required",
			gender : "required",
			location : "required",
			password : "required",
			telephone : "required",
			hometown : "required",
			email: {
				required: true,
				email: true
			},
			shorttext : "required",
		},
		messages: {
			name: "Navn skal udfyldes!",
			gender: "Køn skal udfyldes!",
			location: "Område skal udfyldes!",
			password: "Vælg et kodeord skal udfyldes!",
			telephone: "Telefonnr skal udfyldes!",
			hometown: "Hjemmeside skal udfyldes!",
			email: "Email skal udfyldes!",
			shorttext: "Kort annoncetekst skal udfyldes!"			
		}
	
	});
	
	close_popup=function(){		
		var fel=jQuery('#f_focus').html();
		jQuery('#backoverlay').hide();
		jQuery('#show_popup').hide();
		jQuery('#' + fel ).focus();
  };
  reset_form=function(){
		jQuery('#registerForm')[0].reset()
  };
  click_send=function(){
  	fillpwd();
	fillusername();
	
	document.getElementById('send').click();
  }
  fillpwd=function(){
  	var value = $("#password").val();
  	$("#password2").val(value);
  }
  fillusername=function(){
  	var value = $("#name").val();
  	$("#registerForm #username").val(value);
  }
  checkemail=function(){
  	var email =  $("#registerForm #email").val();
  	$.ajax({
	  type: "POST",
      url: "index.php?option=com_checkemail&task=check",
	  data: "email=" + email,
	  dataType: 'json',
	  success: function(data){
		if(data=='1'){
			jQuery('#alert').html('Email exsits');
			jQuery('#backoverlay').show();
			jQuery('#show_popup').show();
			jQuery('#f_focus').html('Email');
			$("#registerForm #email").val('');
			$("#registerForm #email").focus();			
		}
	  }
	});
  }
   checkusername=function(){
  	var name =  $("#name").val();
  	$.ajax({
	  type: "POST",
      url: "index.php?option=com_checkusername&task=check",
	  data: "name=" + name,
	  dataType: 'json',
	  success: function(data){
		if(data=='1'){
			jQuery('#alert').html('Navn exsits');
			jQuery('#backoverlay').show();
			jQuery('#show_popup').show();
			jQuery('#f_focus').html('name');
			$("#name").val('');
			$("#name").focus();			
		}
	  }
	});
  }
});

</script>
